Esempio n. 1
0
        public void BreakNaturally(Location pos, bool regentrans = true)
        {
            pos = pos.GetBlockLocation();
            Chunk ch = LoadChunk(ChunkLocFor(pos));

            lock (ch.EditSessionLock)
            {
                int           x  = (int)Math.Floor(pos.X) - (int)ch.WorldPosition.X * Chunk.CHUNK_SIZE;
                int           y  = (int)Math.Floor(pos.Y) - (int)ch.WorldPosition.Y * Chunk.CHUNK_SIZE;
                int           z  = (int)Math.Floor(pos.Z) - (int)ch.WorldPosition.Z * Chunk.CHUNK_SIZE;
                BlockInternal bi = ch.GetBlockAt(x, y, z);
                if (((BlockFlags)bi.BlockLocalData).HasFlag(BlockFlags.PROTECTED))
                {
                    return;
                }
                Material mat = (Material)bi.BlockMaterial;
                ch.BlocksInternal[ch.BlockIndex(x, y, z)].BlockLocalData |= (byte)BlockFlags.PROTECTED;
                if (mat != (ushort)Material.AIR)
                {
                    ch.SetBlockAt(x, y, z, new BlockInternal((ushort)Material.AIR, 0, 0, (byte)BlockFlags.EDITED));
                    ch.LastEdited = GlobalTickTime;
                    SurroundRunPhysics(pos);
                    if (regentrans)
                    {
                        ChunkSendToAll(new BlockEditPacketOut(new Location[] { pos }, new ushort[] { 0 }, new byte[] { 0 }, new byte[] { 0 }), ch.WorldPosition);
                    }
                    bi.Material = mat.GetBreaksInto();
                    BlockItemEntity bie = new BlockItemEntity(this, new BlockInternal((ushort)bi._BlockMaterialInternal, bi.BlockData, bi._BlockPaintInternal, 0), pos);
                    SpawnEntity(bie);
                }
            }
        }
Esempio n. 2
0
 public override void SetTextureName(string name)
 {
     if (name == null || name.Length == 0)
     {
         Tex = null;
     }
     else
     {
         if (name.Contains(":") && name.Before(":").ToLowerFast() == "render_block")
         {
             string[] blockDataToRender = name.After(":").SplitFast(',');
             if (blockDataToRender[0] == "self")
             {
                 BlockInternal bi = BlockInternal.FromItemDatum(Datum);
                 RenderedBlock = new BlockItemEntity(TheClient.TheRegion, bi.Material, bi.BlockData, bi.BlockPaint, bi.Damage);
                 RenderedBlock.GenVBO();
             }
             else
             {
                 Material    mat    = MaterialHelpers.FromNameOrNumber(blockDataToRender[0]);
                 byte        data   = (byte)(blockDataToRender.Length < 2 ? 0 : Utilities.StringToInt(blockDataToRender[1]));
                 byte        paint  = (byte)(blockDataToRender.Length < 3 ? 0 : Colors.ForName(blockDataToRender[2]));
                 BlockDamage damage = blockDataToRender.Length < 4 ? BlockDamage.NONE : (BlockDamage)Enum.Parse(typeof(BlockDamage), blockDataToRender[3], true);
                 RenderedBlock = new BlockItemEntity(TheClient.TheRegion, mat, data, paint, damage);
                 RenderedBlock.GenVBO();
             }
             Tex = null;
         }
         if (name.Contains(":") && name.Before(":").ToLowerFast() == "render_model")
         {
             string model = name.After(":");
             if (model.ToLowerFast() == "self")
             {
                 model = GetModelName();
             }
             RenderedModel = new ModelEntity(model, TheClient.TheRegion)
             {
                 Visible = true
             };
             RenderedModel.PreHandleSpawn();
             Tex = null;
         }
         else
         {
             Tex = TheClient.Textures.GetTexture(name);
         }
     }
 }
Esempio n. 3
0
 public BlockItemEntityTag(BlockItemEntity ent)
 {
     Internal = ent;
 }