コード例 #1
0
        public void RemoveIfBlockEntity(int relx, int rely, int relz, BlockType blockAtPos)
        {
            if (BlockEntityDictionary.Get(blockAtPos) == null)
            {
                return;
            }

            foreach (var entity in blockEntities)
            {
                if (entity.pos.x == relx && entity.pos.y == rely && entity.pos.z == relz)
                {
                    blockEntities.Remove(entity);
                    break;
                }
            }
        }
コード例 #2
0
        public void AddIfBlockEntity(int relx, int rely, int relz, BlockType type)
        {
            Type entityType = BlockEntityDictionary.Get(type);

            if (entityType == null)
            {
                return;
            }

            foreach (var e in blockEntities)
            {
                if (e.pos.x == relx && e.pos.y == rely && e.pos.z == relz)
                {
                    return;
                }
            }

            BlockEntity entity = (BlockEntity)Activator.CreateInstance(entityType);

            entity.pos = new Vector3Int(relx, rely, relz);
            blockEntities.Add(entity);
        }