Exemplo n.º 1
0
        private static void ReportClipping(IBlockAccess world, int entityId, Vector3i playerpos, string playerName)
        {
            var hasGap = false;
            var k      = 0;
            var l      = 0;

            for (var i = 0; i < jitterRadius; i++)
            {
                for (var j = 0; j < jitter[i].Count; j++)
                {
                    if (IsTerrain(world, playerpos + jitter[i][j]))
                    {
                        continue;
                    }

                    hasGap = true;
                    k      = i;
                    l      = j;
                    break;
                }
                if (hasGap)
                {
                    break;
                }
            }
            if (hasGap && k == 0)
            {
                return;
            }

            var text = $"CLIP:({entityId}) ({k},{l}) {playerName} {playerpos} - {GameTimer.Instance.ticks}";

            ConnectionManager.Instance.GetClients();
            GameManager.Instance.GameMessageServer(null, EnumGameMessages.Chat, text, "Server", false, string.Empty, false);
        }
Exemplo n.º 2
0
        public int CalculateSkyLights(IBlockAccess level, ChunkColumn[] chunks)
        {
            int       calcCount = 0;
            Stopwatch calcTime  = new Stopwatch();
            int       lastCount = 0;

            foreach (var chunk in chunks)
            {
                if (!_visitedColumns.TryAdd(chunk, true))
                {
                    continue;
                }

                if (chunk.isAllAir)
                {
                    continue;
                }

                calcTime.Restart();
                if (RecalcSkyLight(chunk, level))
                {
                    //calcCount++;

                    //var elapsedMilliseconds = calcTime.ElapsedMilliseconds;
                    //var c = Visits.Sum(pair => pair.Value);
                    //if (elapsedMilliseconds > 0) Log.Debug($"Recalc skylight chunk {chunk.x}, {chunk.z}, count #{calcCount} (air={chunk.isAllAir}) chunks. Time {elapsedMilliseconds}ms and {c - lastCount} visits");
                    //lastCount = c;
                    //PrintVisits();
                }
            }

            //Log.Debug($"Recalc skylight for #{calcCount} chunk. Made {lastCount} visits.");

            return(calcCount);
        }
Exemplo n.º 3
0
        /// <inheritdoc />
        public override BlockState BlockPlaced(IBlockAccess world, BlockState state, BlockCoordinates position)
        {
            if (world is World w)
            {
                if ((w.EntityManager.TryGetBlockEntity(position, out var entity) && !(entity is EnderChestBlockEntity)))
                {
                    w.EntityManager.RemoveBlockEntity(position);
                }

                if (entity is EnderChestBlockEntity)
                {
                    return(base.BlockPlaced(world, state, position));
                }

                var ent = new EnderChestBlockEntity(this, w, BlockEntityFactory.EnderChestTexture)
                {
                    X = position.X & 0xf, Y = position.Y & 0xff, Z = position.Z & 0xf
                };

                w.SetBlockEntity(position.X, position.Y, position.Z, ent);

                /*w.EntityManager.AddBlockEntity(
                 *      position, ent);
                 *
                 * var chunk = world.GetChunk(position, true);
                 *
                 * if (chunk != null)
                 * {
                 *      chunk.AddBlockEntity(new BlockCoordinates(ent.X, ent.Y, ent.Z), ent);
                 * }*/
            }
            return(base.BlockPlaced(world, state, position));
        }
Exemplo n.º 4
0
        public override void setBlockBoundsBasedOnState(IBlockAccess iblockaccess, int i, int j, int k)
        {
            if (isFreestanding)
            {
                return;
            }
            int   l  = iblockaccess.getBlockMetadata(i, j, k);
            float f  = 0.28125F;
            float f1 = 0.78125F;
            float f2 = 0.0F;
            float f3 = 1.0F;
            float f4 = 0.125F;

            setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
            if (l == 2)
            {
                setBlockBounds(f2, f, 1.0F - f4, f3, f1, 1.0F);
            }
            if (l == 3)
            {
                setBlockBounds(f2, f, 0.0F, f3, f1, f4);
            }
            if (l == 4)
            {
                setBlockBounds(1.0F - f4, f, f2, 1.0F, f1, f3);
            }
            if (l == 5)
            {
                setBlockBounds(0.0F, f, f2, f4, f1, f3);
            }
        }
Exemplo n.º 5
0
        private BlockState Check(IBlockAccess world, BlockCoordinates position, BlockCoordinates updatedBlock, BlockState current)
        {
            var neighbor = world.GetBlockState(updatedBlock);

            var facePos = updatedBlock - position;
            var fp      = new Vector3(facePos.X, facePos.Y, facePos.Z);

            fp.Normalize();

            var face       = new Vector3(fp.X, fp.Y, fp.Z).GetBlockFace();
            var faceString = face.ToString().ToLower();

            current.TryGetValue(faceString, out var currentValue);

            if (CanAttach(face, neighbor.Block))
            {
                if (currentValue != "true")
                {
                    return(current.WithProperty(faceString, "true"));
                    //world.SetBlockState(position, state);
                }
            }
            else
            {
                if (currentValue != "false")
                {
                    return(current.WithProperty(faceString, "false"));
                    //world.SetBlockState(position, state);
                }
            }

            return(current);
        }
        /// <summary>
        /// Returns a integer with hex for 0xrrggbb with this color multiplied against the blocks color. Note only called
        /// when first determining what to render.
        /// </summary>
        public override int ColorMultiplier(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
        {
            int i = par1IBlockAccess.GetBlockMetadata(par2, par3, par4);

            if ((i & 3) == 1)
            {
                return(ColorizerFoliage.GetFoliageColorPine());
            }

            if ((i & 3) == 2)
            {
                return(ColorizerFoliage.GetFoliageColorBirch());
            }

            int j = 0;
            int k = 0;
            int l = 0;

            for (int i1 = -1; i1 <= 1; i1++)
            {
                for (int j1 = -1; j1 <= 1; j1++)
                {
                    int k1 = par1IBlockAccess.GetBiomeGenForCoords(par2 + j1, par4 + i1).GetBiomeFoliageColor();
                    j += (k1 & 0xff0000) >> 16;
                    k += (k1 & 0xff00) >> 8;
                    l += k1 & 0xff;
                }
            }

            return((j / 9 & 0xff) << 16 | (k / 9 & 0xff) << 8 | l / 9 & 0xff);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Is this block powering the block on the specified side
        /// </summary>
        public override bool IsPoweringTo(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
        {
            if (!IsRepeaterPowered)
            {
                return(false);
            }

            int i = GetDirection(par1IBlockAccess.GetBlockMetadata(par2, par3, par4));

            if (i == 0 && par5 == 3)
            {
                return(true);
            }

            if (i == 1 && par5 == 4)
            {
                return(true);
            }

            if (i == 2 && par5 == 2)
            {
                return(true);
            }

            return(i == 3 && par5 == 5);
        }
Exemplo n.º 8
0
 public override bool isPoweringTo(IBlockAccess iblockaccess, int i, int j, int k, int l)
 {
     if (!torchActive)
     {
         return false;
     }
     int i1 = iblockaccess.getBlockMetadata(i, j, k);
     if (i1 == 5 && l == 1)
     {
         return false;
     }
     if (i1 == 3 && l == 3)
     {
         return false;
     }
     if (i1 == 4 && l == 2)
     {
         return false;
     }
     if (i1 == 1 && l == 5)
     {
         return false;
     }
     return i1 != 2 || l != 4;
 }
Exemplo n.º 9
0
        /// <summary>
        /// Updates the blocks bounds based on its current state. Args: world, x, y, z
        /// </summary>
        public override void SetBlockBoundsBasedOnState(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
        {
            MaxY = (float)(par1IBlockAccess.GetBlockMetadata(par2, par3, par4) * 2 + 2) / 16F;
            float f = 0.125F;

            SetBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, (float)MaxY, 0.5F + f);
        }
Exemplo n.º 10
0
        public virtual int Func_35296_f(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
        {
            int i = par1IBlockAccess.GetBlockMetadata(par2, par3, par4);

            if (i < 7)
            {
                return(-1);
            }

            if (par1IBlockAccess.GetBlockId(par2 - 1, par3, par4) == FruitType.BlockID)
            {
                return(0);
            }

            if (par1IBlockAccess.GetBlockId(par2 + 1, par3, par4) == FruitType.BlockID)
            {
                return(1);
            }

            if (par1IBlockAccess.GetBlockId(par2, par3, par4 - 1) == FruitType.BlockID)
            {
                return(2);
            }

            return(par1IBlockAccess.GetBlockId(par2, par3, par4 + 1) != FruitType.BlockID ? -1 : 3);
        }
Exemplo n.º 11
0
 //private ConcurrentQueue<LightingItem> LightingQueue { get; }
 public SkyLightCalculator(IBlockAccess blockAccess, IChunkManager chunkManager)
 {
     World       = blockAccess;
     ChunkQueues = new ConcurrentDictionary <ChunkCoordinates, ConcurrentQueue <LightingItem> >();
     //LightingQueue = new ConcurrentQueue<LightingItem>();
     ChunkManager = chunkManager;
 }
Exemplo n.º 12
0
        /// <summary>
        /// Updates the blocks bounds based on its current state. Args: world, x, y, z
        /// </summary>
        public override void SetBlockBoundsBasedOnState(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
        {
            int   i = par1IBlockAccess.GetBlockMetadata(par2, par3, par4) & 7;
            float f = 0.1875F;

            if (i == 1)
            {
                SetBlockBounds(0.0F, 0.2F, 0.5F - f, f * 2.0F, 0.8F, 0.5F + f);
            }
            else if (i == 2)
            {
                SetBlockBounds(1.0F - f * 2.0F, 0.2F, 0.5F - f, 1.0F, 0.8F, 0.5F + f);
            }
            else if (i == 3)
            {
                SetBlockBounds(0.5F - f, 0.2F, 0.0F, 0.5F + f, 0.8F, f * 2.0F);
            }
            else if (i == 4)
            {
                SetBlockBounds(0.5F - f, 0.2F, 1.0F - f * 2.0F, 0.5F + f, 0.8F, 1.0F);
            }
            else
            {
                float f1 = 0.25F;
                SetBlockBounds(0.5F - f1, 0.0F, 0.5F - f1, 0.5F + f1, 0.6F, 0.5F + f1);
            }
        }
Exemplo n.º 13
0
        /// <summary>
        /// Updates the blocks bounds based on its current state. Args: world, x, y, z
        /// </summary>
        public override void SetBlockBoundsBasedOnState(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
        {
            bool  flag  = CanConnectFenceTo(par1IBlockAccess, par2, par3, par4 - 1);
            bool  flag1 = CanConnectFenceTo(par1IBlockAccess, par2, par3, par4 + 1);
            bool  flag2 = CanConnectFenceTo(par1IBlockAccess, par2 - 1, par3, par4);
            bool  flag3 = CanConnectFenceTo(par1IBlockAccess, par2 + 1, par3, par4);
            float f     = 0.375F;
            float f1    = 0.625F;
            float f2    = 0.375F;
            float f3    = 0.625F;

            if (flag)
            {
                f2 = 0.0F;
            }

            if (flag1)
            {
                f3 = 1.0F;
            }

            if (flag2)
            {
                f = 0.0F;
            }

            if (flag3)
            {
                f1 = 1.0F;
            }

            SetBlockBounds(f, 0.0F, f2, f1, 1.0F, f3);
        }
        /// <summary>
        /// Updates the blocks bounds based on its current state. Args: world, x, y, z
        /// </summary>
        public override void SetBlockBoundsBasedOnState(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
        {
            int i = par1IBlockAccess.GetBlockMetadata(par2, par3, par4);

            switch (GetDirectionMeta(i))
            {
            case 0:
                SetBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.25F, 1.0F);
                break;

            case 1:
                SetBlockBounds(0.0F, 0.75F, 0.0F, 1.0F, 1.0F, 1.0F);
                break;

            case 2:
                SetBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 0.25F);
                break;

            case 3:
                SetBlockBounds(0.0F, 0.0F, 0.75F, 1.0F, 1.0F, 1.0F);
                break;

            case 4:
                SetBlockBounds(0.0F, 0.0F, 0.0F, 0.25F, 1.0F, 1.0F);
                break;

            case 5:
                SetBlockBounds(0.75F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
                break;
            }
        }
Exemplo n.º 15
0
        public override bool isPoweringTo(IBlockAccess iblockaccess, int i, int j, int k, int l)
        {
            if (!torchActive)
            {
                return(false);
            }
            int i1 = iblockaccess.getBlockMetadata(i, j, k);

            if (i1 == 5 && l == 1)
            {
                return(false);
            }
            if (i1 == 3 && l == 3)
            {
                return(false);
            }
            if (i1 == 4 && l == 2)
            {
                return(false);
            }
            if (i1 == 1 && l == 5)
            {
                return(false);
            }
            return(i1 != 2 || l != 4);
        }
Exemplo n.º 16
0
        private Color GetGrassBiomeColor(IBlockAccess access, int x, int y, int z)
        {
            var biome = access.GetBiome(new BlockCoordinates(x, y, z));

            return(Resources.ResourcePack.GetGrassColor(
                       biome.Temperature, biome.Downfall, y));
        }
Exemplo n.º 17
0
 public LevelNavigator(Entity entity, IBlockAccess level, double distance, Dictionary <ImprovedTile, Block> blockCache)
 {
     _entity     = entity;
     _level      = level;
     _distance   = distance;
     _blockCache = blockCache;
 }
Exemplo n.º 18
0
        /// <summary>
        /// Updates the blocks bounds based on its current state. Args: world, x, y, z
        /// </summary>
        public override void SetBlockBoundsBasedOnState(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
        {
            int   i    = par1IBlockAccess.GetBlockMetadata(par2, par3, par4);
            int   j    = i & 7;
            bool  flag = (i & 8) > 0;
            float f    = 0.375F;
            float f1   = 0.625F;
            float f2   = 0.1875F;
            float f3   = 0.125F;

            if (flag)
            {
                f3 = 0.0625F;
            }

            if (j == 1)
            {
                SetBlockBounds(0.0F, f, 0.5F - f2, f3, f1, 0.5F + f2);
            }
            else if (j == 2)
            {
                SetBlockBounds(1.0F - f3, f, 0.5F - f2, 1.0F, f1, 0.5F + f2);
            }
            else if (j == 3)
            {
                SetBlockBounds(0.5F - f2, f, 0.0F, 0.5F + f2, f1, f3);
            }
            else if (j == 4)
            {
                SetBlockBounds(0.5F - f2, f, 1.0F - f3, 0.5F + f2, f1, 1.0F);
            }
        }
Exemplo n.º 19
0
        /// <summary>
        /// Returns true if the given side of this block type should be rendered, if the adjacent block is at the given
        /// coordinates.  Args: blockAccess, x, y, z, side
        /// </summary>
        public override bool ShouldSideBeRendered(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
        {
            if (par1IBlockAccess.GetBlockId(par2, par3, par4) == BlockID)
            {
                return(false);
            }

            bool flag  = par1IBlockAccess.GetBlockId(par2 - 1, par3, par4) == BlockID && par1IBlockAccess.GetBlockId(par2 - 2, par3, par4) != BlockID;
            bool flag1 = par1IBlockAccess.GetBlockId(par2 + 1, par3, par4) == BlockID && par1IBlockAccess.GetBlockId(par2 + 2, par3, par4) != BlockID;
            bool flag2 = par1IBlockAccess.GetBlockId(par2, par3, par4 - 1) == BlockID && par1IBlockAccess.GetBlockId(par2, par3, par4 - 2) != BlockID;
            bool flag3 = par1IBlockAccess.GetBlockId(par2, par3, par4 + 1) == BlockID && par1IBlockAccess.GetBlockId(par2, par3, par4 + 2) != BlockID;
            bool flag4 = flag || flag1;
            bool flag5 = flag2 || flag3;

            if (flag4 && par5 == 4)
            {
                return(true);
            }

            if (flag4 && par5 == 5)
            {
                return(true);
            }

            if (flag5 && par5 == 2)
            {
                return(true);
            }

            return(flag5 && par5 == 3);
        }
        /// <summary>
        /// Updates the blocks bounds based on its current state. Args: world, x, y, z
        /// </summary>
        public override void SetBlockBoundsBasedOnState(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
        {
            TileEntityPiston tileentitypiston = GetTileEntityAtLocation(par1IBlockAccess, par2, par3, par4);

            if (tileentitypiston != null)
            {
                Block block = Block.BlocksList[tileentitypiston.GetStoredBlockID()];

                if (block == null || block == this)
                {
                    return;
                }

                block.SetBlockBoundsBasedOnState(par1IBlockAccess, par2, par3, par4);
                float f = tileentitypiston.GetProgress(0.0F);

                if (tileentitypiston.IsExtending())
                {
                    f = 1.0F - f;
                }

                int i = tileentitypiston.GetPistonOrientation();
                MinX = block.MinX - (Facing.OffsetsXForSide[i] * f);
                MinY = block.MinY - (Facing.OffsetsYForSide[i] * f);
                MinZ = block.MinZ - (Facing.OffsetsZForSide[i] * f);
                MaxX = block.MaxX - (Facing.OffsetsXForSide[i] * f);
                MaxY = block.MaxY - (Facing.OffsetsYForSide[i] * f);
                MaxZ = block.MaxZ - (Facing.OffsetsZForSide[i] * f);
            }
        }
Exemplo n.º 21
0
 public Pathfinder(IBlockAccess iblockaccess)
 {
     path        = new Path();
     pointMap    = new MCHashTable();
     pathOptions = new PathPoint[32];
     worldMap    = iblockaccess;
 }
Exemplo n.º 22
0
        /// <summary>
        /// How bright to render this block based on the light its receiving. Args: iBlockAccess, x, y, z
        /// </summary>
        public override float GetBlockBrightness(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
        {
            float f  = par1IBlockAccess.GetLightBrightness(par2, par3, par4);
            float f1 = par1IBlockAccess.GetLightBrightness(par2, par3 + 1, par4);

            return(f <= f1 ? f1 : f);
        }
Exemplo n.º 23
0
        /// <summary>
        /// Returns a integer with hex for 0xrrggbb with this color multiplied against the blocks color. Note only called
        /// when first determining what to render.
        /// </summary>
        public override int ColorMultiplier(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
        {
            if (BlockMaterial == Material.Water)
            {
                int i = 0;
                int j = 0;
                int k = 0;

                for (int l = -1; l <= 1; l++)
                {
                    for (int i1 = -1; i1 <= 1; i1++)
                    {
                        int j1 = par1IBlockAccess.GetBiomeGenForCoords(par2 + i1, par4 + l).WaterColorMultiplier;
                        i += (j1 & 0xff0000) >> 16;
                        j += (j1 & 0xff00) >> 8;
                        k += j1 & 0xff;
                    }
                }

                return((i / 9 & 0xff) << 16 | (j / 9 & 0xff) << 8 | k / 9 & 0xff);
            }
            else
            {
                return(0xffffff);
            }
        }
Exemplo n.º 24
0
        public static bool SetBlock(this IBlockAccess world, int x, int y, int z, string blockName, params string[] args)
        {
            IBlock block = GameData.JavaEdition.GetBlock(blockName);

            if (args == null || args.Length == 0)
            {
                return(world.SetBlock(x, y, z, block.DefaultBlockSet));
            }
            if (args.Length == 1)
            {
                TagCompound tag = NBTFile.FromJson(args[0]);
                return(world.SetBlock(x, y, z, new BlockSet(block, tag)));
            }
            else if ((args.Length & 1) == 0)
            {
                Dictionary <string, string> ps1 = PropertyConverter.From(args);
                foreach (string key in block.DefaultBlockSet.Properties.Keys)
                {
                    if (!ps1.ContainsKey(key))
                    {
                        ps1.Add(key, block.DefaultBlockSet.Properties[key]);
                    }
                }
                return(world.SetBlock(x, y, z, new BlockSet(block, ps1)));
            }
            return(world.SetBlock(x, y, z, block.DefaultBlockSet));
        }
Exemplo n.º 25
0
        /// <inheritdoc />
        public bool Passes(IBlockAccess world, Vector3 position, string rule, string value)
        {
            if (!MultiPartModelHelper.TryGetBlockface(rule, out BlockFace face))
            {
                return(false);
            }

            Vector3 offset = face.GetVector3();

            offset = position + offset;

            if (value == "side|up")
            {
                return(IsRedstoneWire(world, offset) ||
                       IsRedstoneWire(world, offset + Vector3.Down));
            }
            else if (value == "up")
            {
                return(IsRedstoneWire(world, offset + Vector3.Up));
            }
            else if (value == "none")
            {
                return(!IsRedstoneWire(world, offset));
            }

            return(false);
        }
Exemplo n.º 26
0
        public override VerticesResult GetVertices(IBlockAccess world, Vector3 position, Block baseBlock)
        {
            List <BlockShaderVertex> vertices = new List <BlockShaderVertex>();
            List <int> indexes         = new List <int>();
            List <int> animatedIndexes = new List <int>();

            for (var index = 0; index < Models.Length; index++)
            {
                var model = Models[index];
                model.Scale = 1f - (index * 0.001f);

                var verts = model.GetVertices(world, position, baseBlock);

                for (int i = 0; i < verts.Indexes.Length; i++)
                {
                    indexes.Add(vertices.Count + verts.Indexes[i]);
                }

                if (verts.AnimatedIndexes != null)
                {
                    for (int i = 0; i < verts.AnimatedIndexes.Length; i++)
                    {
                        animatedIndexes.Add(vertices.Count + verts.AnimatedIndexes[i]);
                    }
                }

                vertices.AddRange(verts.Vertices);
            }

            return(new VerticesResult(vertices.ToArray(), indexes.ToArray(), animatedIndexes.Count > 0 ? animatedIndexes.ToArray() : null));
        }
Exemplo n.º 27
0
 public virtual bool shouldSideBeRendered(IBlockAccess iblockaccess, int i, int j, int k, int l)
 {
     if (l == 0 && minY > 0.0D)
     {
         return(true);
     }
     if (l == 1 && maxY < 1.0D)
     {
         return(true);
     }
     if (l == 2 && minZ > 0.0D)
     {
         return(true);
     }
     if (l == 3 && maxZ < 1.0D)
     {
         return(true);
     }
     if (l == 4 && minX > 0.0D)
     {
         return(true);
     }
     if (l == 5 && maxX < 1.0D)
     {
         return(true);
     }
     else
     {
         return(!iblockaccess.isBlockOpaqueCube(i, j, k));
     }
 }
Exemplo n.º 28
0
 public override void setBlockBoundsBasedOnState(IBlockAccess iblockaccess, int i, int j, int k)
 {
     if (isFreestanding)
     {
         return;
     }
     int l = iblockaccess.getBlockMetadata(i, j, k);
     float f = 0.28125F;
     float f1 = 0.78125F;
     float f2 = 0.0F;
     float f3 = 1.0F;
     float f4 = 0.125F;
     setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
     if (l == 2)
     {
         setBlockBounds(f2, f, 1.0F - f4, f3, f1, 1.0F);
     }
     if (l == 3)
     {
         setBlockBounds(f2, f, 0.0F, f3, f1, f4);
     }
     if (l == 4)
     {
         setBlockBounds(1.0F - f4, f, f2, 1.0F, f1, f3);
     }
     if (l == 5)
     {
         setBlockBounds(0.0F, f, f2, f4, f1, f3);
     }
 }
Exemplo n.º 29
0
 public Pathfinder(IBlockAccess iblockaccess)
 {
     path = new Path();
     pointMap = new MCHashTable();
     pathOptions = new PathPoint[32];
     worldMap = iblockaccess;
 }
        /// <summary>
        /// Is this block powering the block on the specified side
        /// </summary>
        public override bool IsPoweringTo(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
        {
            if (!TorchActive)
            {
                return(false);
            }

            int i = par1IBlockAccess.GetBlockMetadata(par2, par3, par4);

            if (i == 5 && par5 == 1)
            {
                return(false);
            }

            if (i == 3 && par5 == 3)
            {
                return(false);
            }

            if (i == 4 && par5 == 2)
            {
                return(false);
            }

            if (i == 1 && par5 == 5)
            {
                return(false);
            }

            return(i != 2 || par5 != 4);
        }
Exemplo n.º 31
0
        protected int GetAverageLiquidLevels(IBlockAccess world, BlockCoordinates position, out BlockCoordinates lowest, out int lowestLevel)
        {
            lowest      = BlockCoordinates.Up;
            lowestLevel = 7;

            int level = 0;

            for (int xx = -1; xx < 1; xx++)
            {
                for (int zz = -1; zz < 1; zz++)
                {
                    if (world.GetBlockStates(position.X + xx, position.Y + 1, position.Z + zz).Any(
                            x =>
                    {
                        if (x.State?.VariantMapper.Model is LiquidBlockModel)
                        {
                            return(true);
                        }

                        return(false);
                    }))
                    {
                        return(8);
                    }

                    foreach (var bs in world.GetBlockStates(position.X + xx, position.Y, position.Z + zz))
                    {
                        var b = bs.State;

                        if (!b.Block.Renderable || !(b?.VariantMapper.Model is LiquidBlockModel l))
                        {
                            continue;
                        }

                        if (l.IsLava != IsLava)
                        {
                            continue;
                        }

                        if (TryGetLevel(b, out int lvl))
                        {
                            if (lvl > level)
                            {
                                level = lvl;
                            }

                            if (lvl < lowestLevel)
                            {
                                lowestLevel = lvl;
                                lowest      = new BlockCoordinates(position.X + xx, position.Y, position.Z + zz);
                            }
                        }

                        //break;
                    }
                }
            }

            return(level);
        }
Exemplo n.º 32
0
        public override void setBlockBoundsBasedOnState(IBlockAccess iblockaccess, int i, int j, int k)
        {
            int   l = iblockaccess.getBlockMetadata(i, j, k) & 7;
            float f = 0.1875F;

            if (l == 1)
            {
                setBlockBounds(0.0F, 0.2F, 0.5F - f, f * 2.0F, 0.8F, 0.5F + f);
            }
            else if (l == 2)
            {
                setBlockBounds(1.0F - f * 2.0F, 0.2F, 0.5F - f, 1.0F, 0.8F, 0.5F + f);
            }
            else if (l == 3)
            {
                setBlockBounds(0.5F - f, 0.2F, 0.0F, 0.5F + f, 0.8F, f * 2.0F);
            }
            else if (l == 4)
            {
                setBlockBounds(0.5F - f, 0.2F, 1.0F - f * 2.0F, 0.5F + f, 0.8F, 1.0F);
            }
            else
            {
                float f1 = 0.25F;
                setBlockBounds(0.5F - f1, 0.0F, 0.5F - f1, 0.5F + f1, 0.6F, 0.5F + f1);
            }
        }
Exemplo n.º 33
0
        /// <summary>
        /// Retrieves the block texture to use based on the display side. Args: iBlockAccess, x, y, z, side
        /// </summary>
        public override int GetBlockTexture(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
        {
            if (par5 == 1)
            {
                return(BlockIndexInTexture + 17);
            }

            if (par5 == 0)
            {
                return(BlockIndexInTexture + 17);
            }

            int i = par1IBlockAccess.GetBlockMetadata(par2, par3, par4);

            if (par5 != i)
            {
                return(BlockIndexInTexture);
            }

            if (IsActive)
            {
                return(BlockIndexInTexture + 16);
            }
            else
            {
                return(BlockIndexInTexture - 1);
            }
        }
Exemplo n.º 34
0
 public override bool shouldSideBeRendered(IBlockAccess iblockaccess, int i, int j, int k, int l)
 {
     int i1 = iblockaccess.getBlockId(i, j, k);
     if (!field_6084_a && i1 == blockID)
     {
         return false;
     }
     else
     {
         return base.shouldSideBeRendered(iblockaccess, i, j, k, l);
     }
 }
Exemplo n.º 35
0
 public static bool isPowerProviderOrWire(IBlockAccess iblockaccess, int i, int j, int k)
 {
     int l = iblockaccess.getBlockId(i, j, k);
     if (l == redstoneWire.blockID)
     {
         return true;
     }
     if (l == 0)
     {
         return false;
     }
     return blocksList[l].canProvidePower();
 }
Exemplo n.º 36
0
 public override bool isPoweringTo(IBlockAccess iblockaccess, int i, int j, int k, int l)
 {
     if (!field_22015_c)
     {
         return false;
     }
     int i1 = iblockaccess.getBlockMetadata(i, j, k) & 3;
     if (i1 == 0 && l == 3)
     {
         return true;
     }
     if (i1 == 1 && l == 4)
     {
         return true;
     }
     if (i1 == 2 && l == 2)
     {
         return true;
     }
     return i1 == 3 && l == 5;
 }
Exemplo n.º 37
0
 public override void setBlockBoundsBasedOnState(IBlockAccess iblockaccess, int i, int j, int k)
 {
     if (iblockaccess.getBlockId(i - 1, j, k) == blockID || iblockaccess.getBlockId(i + 1, j, k) == blockID)
     {
         float f = 0.5F;
         float f2 = 0.125F;
         setBlockBounds(0.5F - f, 0.0F, 0.5F - f2, 0.5F + f, 1.0F, 0.5F + f2);
     }
     else
     {
         float f1 = 0.125F;
         float f3 = 0.5F;
         setBlockBounds(0.5F - f1, 0.0F, 0.5F - f3, 0.5F + f1, 1.0F, 0.5F + f3);
     }
 }
Exemplo n.º 38
0
 public override bool shouldSideBeRendered(IBlockAccess iblockaccess, int i, int j, int k, int l)
 {
     return true;
 }
Exemplo n.º 39
0
 public override void setBlockBoundsBasedOnState(IBlockAccess iblockaccess, int i, int j, int k)
 {
     int l = iblockaccess.getBlockMetadata(i, j, k);
     int i1 = l & 7;
     bool flag = (l & 8) > 0;
     float f = 0.375F;
     float f1 = 0.625F;
     float f2 = 0.1875F;
     float f3 = 0.125F;
     if (flag)
     {
         f3 = 0.0625F;
     }
     if (i1 == 1)
     {
         setBlockBounds(0.0F, f, 0.5F - f2, f3, f1, 0.5F + f2);
     }
     else if (i1 == 2)
     {
         setBlockBounds(1.0F - f3, f, 0.5F - f2, 1.0F, f1, 0.5F + f2);
     }
     else if (i1 == 3)
     {
         setBlockBounds(0.5F - f2, f, 0.0F, 0.5F + f2, f1, f3);
     }
     else if (i1 == 4)
     {
         setBlockBounds(0.5F - f2, f, 1.0F - f3, 0.5F + f2, f1, 1.0F);
     }
 }
Exemplo n.º 40
0
 public override void setBlockBoundsBasedOnState(IBlockAccess iblockaccess, int i, int j, int k)
 {
     setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
 }
Exemplo n.º 41
0
 public virtual bool isPoweringTo(IBlockAccess iblockaccess, int i, int j, int k, int l)
 {
     return false;
 }
Exemplo n.º 42
0
 public override bool shouldSideBeRendered(IBlockAccess iblockaccess, int i, int j, int k, int l)
 {
     return base.shouldSideBeRendered(iblockaccess, i, j, k, 1 - l);
 }
Exemplo n.º 43
0
 public virtual bool shouldSideBeRendered(IBlockAccess iblockaccess, int i, int j, int k, int l)
 {
     if (l == 0 && minY > 0.0D)
     {
         return true;
     }
     if (l == 1 && maxY < 1.0D)
     {
         return true;
     }
     if (l == 2 && minZ > 0.0D)
     {
         return true;
     }
     if (l == 3 && maxZ < 1.0D)
     {
         return true;
     }
     if (l == 4 && minX > 0.0D)
     {
         return true;
     }
     if (l == 5 && maxX < 1.0D)
     {
         return true;
     }
     else
     {
         return !iblockaccess.isBlockOpaqueCube(i, j, k);
     }
 }
Exemplo n.º 44
0
 public virtual void setBlockBoundsBasedOnState(IBlockAccess iblockaccess, int i, int j, int k)
 {
 }
Exemplo n.º 45
0
 public override void setBlockBoundsBasedOnState(IBlockAccess iblockaccess, int i, int j, int k)
 {
     bool flag = iblockaccess.getBlockMetadata(i, j, k) == 1;
     float f = 0.0625F;
     if (flag)
     {
         setBlockBounds(f, 0.0F, f, 1.0F - f, 0.03125F, 1.0F - f);
     }
     else
     {
         setBlockBounds(f, 0.0F, f, 1.0F - f, 0.0625F, 1.0F - f);
     }
 }
Exemplo n.º 46
0
 public override void setBlockBoundsBasedOnState(IBlockAccess iblockaccess, int i, int j, int k)
 {
     int l = iblockaccess.getBlockMetadata(i, j, k);
     float f = 0.0625F;
     float f1 = (1 + l*2)/16F;
     float f2 = 0.5F;
     setBlockBounds(f1, 0.0F, f, 1.0F - f, f2, 1.0F - f);
 }
Exemplo n.º 47
0
 public override void setBlockBoundsBasedOnState(IBlockAccess iblockaccess, int i, int j, int k)
 {
     int l = iblockaccess.getBlockMetadata(i, j, k);
     if (l >= 2 && l <= 5)
     {
         setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.625F, 1.0F);
     }
     else
     {
         setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.125F, 1.0F);
     }
 }
Exemplo n.º 48
0
 public override bool isPoweringTo(IBlockAccess iblockaccess, int i, int j, int k, int l)
 {
     if (!wiresProvidePower)
     {
         return false;
     }
     if (iblockaccess.getBlockMetadata(i, j, k) == 0)
     {
         return false;
     }
     if (l == 1)
     {
         return true;
     }
     bool flag = isPowerProviderOrWire(iblockaccess, i - 1, j, k) ||
                 !iblockaccess.isBlockOpaqueCube(i - 1, j, k) &&
                 isPowerProviderOrWire(iblockaccess, i - 1, j - 1, k);
     bool flag1 = isPowerProviderOrWire(iblockaccess, i + 1, j, k) ||
                  !iblockaccess.isBlockOpaqueCube(i + 1, j, k) &&
                  isPowerProviderOrWire(iblockaccess, i + 1, j - 1, k);
     bool flag2 = isPowerProviderOrWire(iblockaccess, i, j, k - 1) ||
                  !iblockaccess.isBlockOpaqueCube(i, j, k - 1) &&
                  isPowerProviderOrWire(iblockaccess, i, j - 1, k - 1);
     bool flag3 = isPowerProviderOrWire(iblockaccess, i, j, k + 1) ||
                  !iblockaccess.isBlockOpaqueCube(i, j, k + 1) &&
                  isPowerProviderOrWire(iblockaccess, i, j - 1, k + 1);
     if (!iblockaccess.isBlockOpaqueCube(i, j + 1, k))
     {
         if (iblockaccess.isBlockOpaqueCube(i - 1, j, k) && isPowerProviderOrWire(iblockaccess, i - 1, j + 1, k))
         {
             flag = true;
         }
         if (iblockaccess.isBlockOpaqueCube(i + 1, j, k) && isPowerProviderOrWire(iblockaccess, i + 1, j + 1, k))
         {
             flag1 = true;
         }
         if (iblockaccess.isBlockOpaqueCube(i, j, k - 1) && isPowerProviderOrWire(iblockaccess, i, j + 1, k - 1))
         {
             flag2 = true;
         }
         if (iblockaccess.isBlockOpaqueCube(i, j, k + 1) && isPowerProviderOrWire(iblockaccess, i, j + 1, k + 1))
         {
             flag3 = true;
         }
     }
     if (!flag2 && !flag1 && !flag && !flag3 && l >= 2 && l <= 5)
     {
         return true;
     }
     if (l == 2 && flag2 && !flag && !flag1)
     {
         return true;
     }
     if (l == 3 && flag3 && !flag && !flag1)
     {
         return true;
     }
     if (l == 4 && flag && !flag2 && !flag3)
     {
         return true;
     }
     return l == 5 && flag1 && !flag2 && !flag3;
 }
Exemplo n.º 49
0
 public override bool shouldSideBeRendered(IBlockAccess iblockaccess, int i, int j, int k, int l)
 {
     if (this != stairSingle)
     {
         base.shouldSideBeRendered(iblockaccess, i, j, k, l);
     }
     if (l == 1)
     {
         return true;
     }
     if (!base.shouldSideBeRendered(iblockaccess, i, j, k, l))
     {
         return false;
     }
     if (l == 0)
     {
         return true;
     }
     else
     {
         return iblockaccess.getBlockId(i, j, k) != blockID;
     }
 }
Exemplo n.º 50
0
 public override bool isPoweringTo(IBlockAccess iblockaccess, int i, int j, int k, int l)
 {
     return (iblockaccess.getBlockMetadata(i, j, k) & 8) > 0;
 }
Exemplo n.º 51
0
 public override void setBlockBoundsBasedOnState(IBlockAccess iblockaccess, int i, int j, int k)
 {
     int l = iblockaccess.getBlockMetadata(i, j, k) & 7;
     float f = 0.1875F;
     if (l == 1)
     {
         setBlockBounds(0.0F, 0.2F, 0.5F - f, f*2.0F, 0.8F, 0.5F + f);
     }
     else if (l == 2)
     {
         setBlockBounds(1.0F - f*2.0F, 0.2F, 0.5F - f, 1.0F, 0.8F, 0.5F + f);
     }
     else if (l == 3)
     {
         setBlockBounds(0.5F - f, 0.2F, 0.0F, 0.5F + f, 0.8F, f*2.0F);
     }
     else if (l == 4)
     {
         setBlockBounds(0.5F - f, 0.2F, 1.0F - f*2.0F, 0.5F + f, 0.8F, 1.0F);
     }
     else
     {
         float f1 = 0.25F;
         setBlockBounds(0.5F - f1, 0.0F, 0.5F - f1, 0.5F + f1, 0.6F, 0.5F + f1);
     }
 }